package com.itheima.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

/**
 * @program: Spring_day01_01_IOC入门程序
 * @description: 通知（切面类）
 * @author: xuejingjing
 * @create: 2021-08-03 10:30
 **/

@Component
@Aspect  //这个类是个切面类，里面的方法做通知功能
public class AOPAdvice {

    //配置切入点 pt是切入点id
//    @Pointcut("execution(* *..*(..))")
//    public void pt(){
//
//    }

    @Before("AOPPointcut.pt()")
    public void XJJ_before(){
        System.out.println("前置before...");
    }


    @After("AOPPointcut.pt()")
    public void XJJ_after(){
        System.out.println("后置after...");
    }

    @AfterReturning("AOPPointcut.pt()")
    public void XJJ_afterReturning(){
        System.out.println("返回后afterReturning...");
    }

    @AfterThrowing("AOPPointcut.pt()")
    public void XJJ_afterThrowing(){
        System.out.println("跑出异常后afterThrowing...");
    }

    @Around("AOPPointcut.pt()")
    public Object around(ProceedingJoinPoint pjp) throws Throwable {
        System.out.println("环绕前around before...");
        Object proceed = pjp.proceed();
        System.out.println("环绕后around after...");
        return proceed;
    }

}
